#include <iostream>
#include <string.h>
#include <fstream>
#include "huffmanCompress.h"
//using namespace std;

int main(int argc, char *argv[])
{
    if(argc == 4 &&
            (strcmp(argv[1], "-c") == 0 || strcmp(argv[1], "-d") == 0))
    {
        std::fstream tmpFile;
        tmpFile.open(argv[2], std::ios::in);
        if(!tmpFile)
        {
            std::cout << "ERROR: no such file: " << argv[2] << std::endl;
            return 0;
        }
        tmpFile.close();

        if(strcmp(argv[1], "-c") == 0)
        {
            huffmanCompress(argv[2], argv[3]);
        }
        else
        {
            huffmanDecompress(argv[2], argv[3]);
        }

    }
    else
    {

        std::cout << "Usage:\n"
                  << "\tcompress file: -c <ori> <out>\n"
                  << "\tdecompress file: -d <compressed> <out>"
                  << std::endl;
    }
    return 1;
}
